﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;
/// <summary>
///AdminLogin 的摘要说明
/// </summary>
public class AdminLogin
{
	public AdminLogin()
	{
		//
		//TODO: 在此处添加构造函数逻辑
		//
	}
    private SqlCommand cmd;
    public string LoginSys(string name,string pwd)
    {
        string result = "0";
        try
        {
            cmd = new SqlCommand("select count(*) from adminer where aname=@aname and apwd=@apwd", ConDB.GetOpen());
            cmd.Parameters.Add("@aname", SqlDbType.VarChar,10).Value = name;
            cmd.Parameters.Add("@apwd", SqlDbType.VarChar).Value = pwd;
            int x = Convert.ToInt32(cmd.ExecuteScalar());
            if (x > 0)
            {
                result = "1";
            }
        }
        catch (Exception e)
        {
            result = "0";
        }
        finally
        {
            ConDB.Close();
        }
        return result;
    }
    public string addadminer(string name, string pwd)
    {
        string result = "0";
        try
        {
            cmd = new SqlCommand("insert adminer values(@aname,@apwd)", ConDB.GetOpen());
            cmd.Parameters.Add("@aname", SqlDbType.VarChar).Value = name;
            cmd.Parameters.Add("@apwd", SqlDbType.VarChar).Value = pwd;
            int x = cmd.ExecuteNonQuery();
            if (x > 0)
            {
                result = "1";
            }
        }
        catch (Exception e)
        {
            result = "0";
        }
        finally
        {
            ConDB.Close();
        }
        return result;
    }
}
